Skip to content

fix(durable): dispatch the effects of a parent transition an actor drives - #270

Merged
reka18 merged 4 commits into
mainfrom
fix/durable-actor-driven-effects
Nov 25, 2026
Merged

reka18 merged 4 commits into
mainfrom
fix/durable-actor-driven-effects

Conversation

@reka18

@reka18 reka18 commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

What this does

A parent transition that an actor drives can emit domain effects, such as an email or a charge. durable never dispatched them, either live or on Recover. The same transition dispatched its effects when the host reached it through Handle.Fire, and dropped them silently when an actor drove it.

Now every step adds the effects of the parent Fires its actors drove after its own, and dispatches them. This holds for:

  • Fire, when an actor spawned during the step settles or fails;
  • Tick, when a timer enters a state that spawns an actor;
  • the RunService settle, including when an actor the step drove aborts and the Handle fails: the settle the step records names the driven effects, so they still dispatch;
  • DeliverToActor.

Replay adds the same effects into the step's dispatch list, so a Recover after a crash between Append and dispatch sends them with the same deterministic ids.

Effect order. A step's own effects come first, then each actor-driven parent Fire's effects in fire order. The EffectID godoc says so, and a test pins the ids live and on Recover.

DeliverToActor now dispatches outside the step lock, the way Fire, Tick and RunService already finish. That way a dispatch handler can call back into the Handle. The step is marked as dispatching before the lock is released, so Drain and a later Recover see it.

There's no journal format change. A parent Fire driven by an actor that Start or Recover spawned is out of scope, and is tracked in #269.

Tests

  • TestFire_DispatchesTheEffectsOfAParentFireAnActorDrove is no longer skipped.
  • TestActorDrivenFire_DispatchesItsDomainEffects covers Fire, DeliverToActor, Tick and RunService, both live and on Recover after a crash before dispatch.
  • TestActorDrivenFire_EffectIDsPutTheStepsOwnFirst pins the order.
  • TestActorDrivenFire_DispatchesOnAServiceSettleAnActorAbortedIn covers the RunService settle when an actor abort fails the Handle, both live and on Recover.
  • Dropping the change at any one seam fails only that seam's case. Dropping the replay change fails every Recover case.

Checks

  • mage check passes in every module (go1.27.4)
  • CHANGELOG entry

Also in this PR

TestWithSettleTransform_ARewrittenFailureNothingRoutesEscalates now covers the InvokeActor path as well as Spawn: a transform flips an invoked actor's failure to success with no onDone wired, and the original error escalates. It answers a #268 review comment. It came after #268's approval, so it rides here. It's test-only.

Closes #257

@reka18 reka18 added ready All ACR dimensions confirmed - clear to merge confirmed:correctness ACR clean: correctness confirmed:regression-safety ACR clean: regression-safety confirmed:concurrency-discipline ACR clean: concurrency-discipline confirmed:replay-determinism ACR clean: replay-determinism confirmed:api-compatibility ACR clean: api-compatibility confirmed:missed-context ACR clean: missed-context confirmed:human-readability ACR clean: human-readability confirmed:probes ACR: the probes lens's latest round found no blocker labels Nov 18, 2026
@reka18

reka18 commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

Review findings

The AI reviewers' pass over this change checked every review label and found nothing. Five candidates were raised, and each was refuted against the code:

  1. Dispatch outside the lock in DeliverToActor, against Drain and a handoff to Recover. The step is marked as dispatching before the lock is released, and Drain waits for it, the same as for Fire.
  2. A dispatch handler that calls DeliverToActor again. The lock is free, and a settled actor refuses the delivery, which matches Fire's existing contract.
  3. Effect order in a Tick, live against replay. Nothing can drive an actor while the scheduler ticks, and both sides put the timers' effects first, then the driven Fires'.
  4. A refused parent Fire. The kernel clears its effects on every failure path, so neither the live run nor the replay dispatches any.
  5. A delivery Record with entries from Start or Recover spawns. Both sides leave those out of the dispatch list. durable: domain effects of a parent Fire an actor spawned by Start or Recover drives are never dispatched #269 tracks them.

@reka18

reka18 commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

Decisions for Temple to ratify

I made these calls in this PR. Each is a suggestion for you to confirm or change.

  1. Effect order within a step: the step's own effects come first, then each actor-driven parent Fire's effects in fire order. That order sets the deterministic effect ids (step#ordinal#kind), live and on Recover.
  2. No journal format bump. durable is greenfield, so a journal written before this change also dispatches its actor-driven effects on Recover. Those are effects the older version never sent.
  3. DeliverToActor now dispatches outside the step lock, the way Fire, Tick and RunService already finish, so a dispatch handler can call back into the Handle.
  4. Out of scope: a parent Fire driven by an actor that Start or Recover spawned still drops its effects. It's filed as durable: domain effects of a parent Fire an actor spawned by Start or Recover drives are never dispatched #269, with the open question of when those effects should go out.

@reka18
reka18 force-pushed the fix/durable-actor-outcome-replay branch from 23391d7 to 681f0ef Compare November 23, 2026 18:42
Base automatically changed from fix/durable-actor-outcome-replay to main November 24, 2026 19:29
…or's failure with no onDone

Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
…ives

A parent Fire an actor drove — a failed spawn's onError during a Fire, a
Tick, or a service settle's transition, or a settle or message a
DeliverToActor delivery drove — was journaled with the driving step, but
its domain effects were never named among the step's, so the
EffectHandler never applied them, live or on Recover: the id the effect
would have carried deduplicated nothing, because no dispatch ever
happened to deduplicate.

- durable: drivenFireEffects appends a driven Fire's effects after the
  driving step's own, in fire order, and fireStep, tickStep,
  DeliverToActor and the RunService settle all name them through
  recordStep, so they dispatch under the same deterministic ids as any
  step effect.
- durable: replayActors returns the effects of the transitions it
  re-fires, and replayRecord folds them into the step's effects after
  its own work, so Recover re-dispatches a driven Fire's effect that a
  crash kept from landing, exactly once. The Fires an actor spawned by
  Start or Recover drives still dispatch none, live and on replay: that
  gap is filed separately as #269.
- durable: DeliverToActor now dispatches after releasing the step lock,
  as Fire does, since a delivery's step can name effects, and an effect
  handler must be able to call back into the same Handle.
- durable: the EffectID contract states the order: a step's own effects
  first, then each actor-driven parent Fire's, in fire order, identical
  live and on Recover, so the ordinal component places a driven Fire's
  effect the same way on both.

Closes #257.

Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
@reka18
reka18 force-pushed the fix/durable-actor-driven-effects branch from 685a0a4 to 1e2f238 Compare November 24, 2026 19:40
@reka18
reka18 requested a review from joshua-temple November 24, 2026 19:49
@reka18 reka18 added not-ready On every new PR until all review dimensions are confirmed wait:correctness ACR pending: correctness wait:regression-safety ACR pending: regression-safety wait:concurrency-discipline ACR pending: concurrency-discipline and removed ready All ACR dimensions confirmed - clear to merge confirmed:correctness ACR clean: correctness confirmed:regression-safety ACR clean: regression-safety confirmed:concurrency-discipline ACR clean: concurrency-discipline confirmed:replay-determinism ACR clean: replay-determinism confirmed:api-compatibility ACR clean: api-compatibility confirmed:missed-context ACR clean: missed-context labels Nov 24, 2026
@reka18 reka18 added wait:missed-context ACR pending: missed-context wait:human-readability ACR pending: human-readability wait:probes ACR: the probes lens is still open labels Nov 24, 2026
…dler calling back into the Handle

Follow-up to the review of #270: the DeliverToActor doc named the dispatch
but not what a failure of it leaves behind, where Fire, Tick and RunService
each do; and nothing pinned that a delivery dispatches after releasing the
step lock, so its effect handler can call back into the same Handle.

- durable: the DeliverToActor doc states the failed-dispatch mode as its
  siblings do: a failed dispatch fails the Handle with ErrHandleFailed;
  the step stays recorded, and Recover sends its effects.
- durable: TestDeliverToActor_AnEffectHandlerCallsBackIntoTheHandle pins
  that an effect handler dispatched from a delivery's step — one naming
  the effects of the parent Fires it drove — can View and Fire on the same
  Handle, both succeeding without deadlock or ErrReentrantStep, bounded by
  waitFor so a dispatch under the step lock fails the test rather than
  hanging it.

Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
@reka18 reka18 added ready All ACR dimensions confirmed - clear to merge confirmed:correctness ACR clean: correctness confirmed:regression-safety ACR clean: regression-safety confirmed:concurrency-discipline ACR clean: concurrency-discipline confirmed:replay-determinism ACR clean: replay-determinism confirmed:api-compatibility ACR clean: api-compatibility confirmed:missed-context ACR clean: missed-context confirmed:human-readability ACR clean: human-readability confirmed:probes ACR: the probes lens's latest round found no blocker and removed not-ready On every new PR until all review dimensions are confirmed wait:correctness ACR pending: correctness wait:regression-safety ACR pending: regression-safety wait:concurrency-discipline ACR pending: concurrency-discipline wait:replay-determinism ACR pending: replay-determinism wait:api-compatibility ACR pending: api-compatibility wait:missed-context ACR pending: missed-context wait:human-readability ACR pending: human-readability wait:probes ACR: the probes lens is still open labels Nov 24, 2026
@reka18
reka18 marked this pull request as ready for review November 24, 2026 20:07

@joshua-temple joshua-temple left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • One medium finding inline: the published exactly-once contract still says actor-driven parent transitions are not dispatched.
  • Checked: live naming vs replay order on Fire, Tick, DeliverToActor, RunService; Start/Recover before entries excluded on both sides; refused Fires carry no effects (state/fire.go:160).
  • Checked: delete-the-fix on each seam and on replay fails the new tests; own/driven order swap fails the id test; go test -race -count=30 on the new tests is clean.

Comment thread durable/effect.go Resolved
… once

The published exactly-once contract still said a parent transition an
actor drives 'isn't dispatched'. Since 1e2f238 a step an actor system
drove dispatches the domain effects of the parent Fires it drove as its
own, live and on Recover. Update the three places the old claim lives —
the package doc, the module README, and the durable overview page — to
state the new contract, with the remaining gap kept explicit: an actor
spawned by Start or Recover still drives parent transitions whose
effects are not dispatched yet (#269), and Runner.Start's initial entry
remains at-least-once.

Closes the docs part of Temple's review of #270.

Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>

@joshua-temple joshua-temple left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Live dispatch and recovery replay match on all 4 paths
  • Removing the fix fails the new tests
  • Docs gap noted in prior review, non-blocking

@reka18
reka18 merged commit 7e4978a into main Nov 25, 2026
112 checks passed
@reka18
reka18 deleted the fix/durable-actor-driven-effects branch November 25, 2026 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

confirmed:api-compatibility ACR clean: api-compatibility confirmed:concurrency-discipline ACR clean: concurrency-discipline confirmed:correctness ACR clean: correctness confirmed:human-readability ACR clean: human-readability confirmed:missed-context ACR clean: missed-context confirmed:probes ACR: the probes lens's latest round found no blocker confirmed:regression-safety ACR clean: regression-safety confirmed:replay-determinism ACR clean: replay-determinism ready All ACR dimensions confirmed - clear to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

durable: domain effects of a parent transition an actor drives are never dispatched

2 participants